/* 自定义异常 */
#include <iostream>
#include <string>

using namespace std;

class OutOfRange:public exception
{
public:
#if 1
    OutOfRange(string str)
    {
        error = str;
    }
#endif
    OutOfRange(const char *str)
    {
        error = str;
    }

    virtual const char *what() const noexcept
    {
        return error.c_str();
    }
private:
    string error;
};

int main(int argc, char **argv)
{

    try 
    {
        throw OutOfRange("hello");
    }
    catch (exception &ob)
    {
        cout << ob.what() << endl;
    }

    cout << "haha" << endl;


    return 0;
}